﻿using CommonBase;
using MContracts.Classes;
using MContracts.Controls.Dialogs;
using McReports;
using McReports.Common;
using McReports.ViewModel;
using McUIBase.Factories;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MContracts.ViewModel
{
	/// <summary>
	/// Определяет регион создания отчётов
	/// </summary>
    partial class MainWindowViewModel : IDateRange
    {
        #region Reports

        private void CreateExcelYearPlanReport_1()
        {
            throw new NotImplementedException();
            //ReportCreatorHelper.CreateYearTemplanReport(this);
        }


        /// <summary>
        /// текущая справка по договорам
        /// </summary>
        private void CreateExcelInformationReport_2()
        {
            using (
                var viewModel = new ContractRegisterReport_2_ViewModel(RepositoryFactory.CreateContractRepository()) { Period = Range })
            {
                CreateReport(viewModel);
            }
        }

        private static ITemplateProvider CreateTemplateProvider()
        {
            return new DefaultTemplateProvider
                (AppDomain.CurrentDomain.BaseDirectory, Properties.Settings.Default.ReportTemplateFolder, Properties.Settings.Default);
        }

        private void CreateReport(BaseReportViewModel reportViewModel)
        {
            reportViewModel.TemplateProvider = CreateTemplateProvider();

            var factory = new ReportFactoryBase
                {
                    UiQueryParametersProvider = new ReportParamsWindow {ViewModel = reportViewModel}
                };

            factory.CreateReport(reportViewModel);
        }



        /// <summary>
        /// текущая справка по договорам на переходный период
        /// </summary>
        private void CreateExcelContractsPeriodReport_3()
        {
            using (
                var viewModel = new ContractPeriodReport_3_ViewModel(RepositoryFactory.CreateContractRepository()) { Period = Range })
            {
                CreateReport(viewModel);
            }
        }

        private void CreateExcelContractQuarterPlanReport_4()
        {
            using (
                var viewModel = new ContractQuarterPlanRepot_4_ViewModel(RepositoryFactory.CreateContractRepository()) { Period = Range })
            {
                CreateReport(viewModel);
            }
        }

        private void CreateExcelSubContractReport_5()
        {
            using (
                var viewModel = new SubContractRegisterReport_5_ViewModel(RepositoryFactory.CreateContractRepository()) { Period = Range })
            {
                CreateReport(viewModel);
            }
        }


        private void CreateExcelHandingWorkReport_6()
        {
            using (
                var viewModel = new HandingWorkReport_6_ViewModel(RepositoryFactory.CreateContractRepository()) { Period = Range })
            {
                CreateReport(viewModel);
            }
        }


        private void CreateExcelEfficientInformationReport_7()
        {
            using (
                var viewModel =
                    new EfficientInformationMonthReport_7_ViewModel(RepositoryFactory.CreateContractRepository()) { Period = Range })
            {
                CreateReport(viewModel);
            }
        }

        private void CreateExcelEfficientInformationReport_7_1()
        {
            using (
                var viewModel =
                    new EfficientInformationQuarterReport_7_ViewModel(RepositoryFactory.CreateContractRepository()) { Period = Range })
            {
                CreateReport(viewModel);
            }
        }



        private void CreateTransferActsContractsReport_8_1()
        {
            //var viewModel = new TransferActsContractsReport_8_1_ViewModel(RepositoryFactory.CreateContractRepository());
            //ReportFactory.CreateReport(viewModel);
        }

        private void CreateTransferContractsReport_8_2()
        {
            //var viewModel = new TransferContractsReport_8_2_ViewModel(RepositoryFactory.CreateContractRepository());
            //ReportFactory.CreateReport(viewModel);
        }

        #endregion

        public DateRange Range
        {
            get
            {
                return new DateRange() { Start = this.SelectedFilterStartDate, End = SelectedFilterEndDate };
            }
            set
            {
                throw new NotImplementedException();
            }
        }
    }
}
